/*
  Copyright 2011 fullkawa

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package jp.fullkawa.xnovel.content;

/**
 * 文章
 * 必ずしも一文まるまる(句点まで)とは限らない。@see ContentWithRuby
 * @author fullkawa
 */
public class Sentence extends Content
{
	private String sentence;

	/**
	 * 改行
	 */
	private boolean br = true;

	public Sentence() {}

	public Sentence(String sentence)
	{
		this();
		this.setSentence(sentence);
	}

	public Sentence(String sentence, boolean br)
	{
		this(sentence);
		this.setBr(br);
	}

	public String getSentence() {
		return sentence;
	}

	public void setSentence(String sentence) {
		this.sentence = sentence;
	}

	public boolean isBr() {
		return br;
	}

	public void setBr(boolean br) {
		this.br = br;
	}

	@Override
	public String getTag()
	{
		String tag_br = "";
		if (this.isBr()) {
			Object[] o = null;
			tag_br = super.getTag("tag.sentence.br", o);
		}

		/* 改行だけしたい場合があるかもしれないから、OKとする
		if (this.getSentence() == null || this.getSentence().length() == 0)
		{
			throw new RequireException("文章が入力されていません。");
		}
		*/
		Object[] o = { this.getSentence() };
		return super.getTag("tag.sentence", o) + tag_br;
	}
}
